package com.zjx.springcloud.service.impl;

import com.zjx.springcloud.dao.DeptDao;
import com.zjx.springcloud.entities.Dept;
import com.zjx.springcloud.redis.RedisUtil;
import com.zjx.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import javax.annotation.Resource;
import java.util.List;
@Service
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public class DeptServiceImpl implements DeptService {
    @Resource
    private DeptDao deptDao;
    @Resource
    private RedisUtil redisUtil;
    @Override
    public List<Dept> queryDeptAll() {
//        try {
//
//        }catch (Exception e){
//            e.printStackTrace();
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//        }

        redisUtil.set("sss","dads",60*3);
        return deptDao.queryDeptAll();
    }
}
